<template>
  <!-- 过渡动画 -->
  <transition name="fade">
    <div class="img-view"
         @click="closeBigImg">
      <img :src="imgSrc"
           alt="加载失败">
    </div>
  </transition>
</template>
<script>
export default {
  props: ['imgSrc'],
  methods: {
    closeBigImg () {
      // 发送事件
      this.$emit('clickBigImg')
    }
  }
}
</script>
<style scoped>
/*动画*/
.fade-enter-active,
.fade-leave-active {
  transition: all 0.2s linear;
  transform: translate3D(0, 0, 0);
}
.fade-enter,
.fade-leave-active {
  transform: translate3D(100%, 0, 0);
}

/* bigimg */
.img-view {
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.7);
  width: 100%;
  height: 100%;
  overflow: hidden;
}
/*不限制图片大小，实现居中*/
.img-view img {
  width: 800px;
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  z-index: 10000;
}
</style>